{extend name="web/public/base" /}
{block name="header"}
{/block}
{block name="main"}
<section class="scrollable padder">
    <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">会员管理</li>
        <li class="active">{$title}</li>
    </ul>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel panel-default">
                <header class="panel-heading font-bold">{$title}</header>
                <div class="panel-body">
                    <form id="ajaxform" action="{:url('edit')}" method="post" onsubmit="return false;">

                        <div class="row col-lg-12">

                            <div class="form-group col-sm-6">
                                <label>代理商分红总额</label>
                                <input type="text" id="money1" name="money1" class="form-control" placeholder="代理商分红总额"
                                       value="{$dayInfo.money1}">
                            </div>
                            <div class="form-group col-sm-6">
                                <label>经销商分红总额</label>
                                <input type="text" id="money2" name="money2" class="form-control" placeholder="经销商分红总额"
                                       value="{$dayInfo.money2}">
                            </div>
                        </div>


                        <footer class="panel-footer text-right bg-light lter col-sm-12">
                            <input type="hidden" name="id" value="{$dayInfo.id}">
                            <input type="hidden" name="code" value="">
                            <button type="submit" class="btn btn-success btn-s-xs">提 交</button>
                        </footer>
                    </form>
                </div>
            </section>
        </div>

    </div>
</section>
{/block}
{block name="script"}
<script src="__PUBLIC__/area.js"></script>
<script>
    $(function () {
        layer.config({extend: 'extend/layer.ext.js'})
        $.validator.setDefaults({
            submitHandler: function () {
                var email = "{$email}";
                if (!email) {
                    layer.msg("邮箱不存在")
                    return false;
                }
                tijiao(email)
            },
            highlight: function (element, errorClass) {
                $(element).css('border', '2px solid red');
            },
            unhighlight: function (element, errorClass) {
                $(element).css('border', '1px solid green');
            }
        });

        $('#ajaxform').validate({

        });

        function tijiao(email) {
            $.post("/index/Home/getEmailCode", {email: email}, function (data) {
                var code = data.substr(data.length - 1, 1)
                if (code == 0) {
                    layer.msg('邮箱验证码发送失败！');
                    return false;
                }
                layer.prompt({
                    title: '请输入您的邮箱收到的验证码',
                }, function (value, index, elem) {

                    var reg = new RegExp("^[0-9]{6}$");
                    if (!reg.test(value)) {
                        layer.msg("请输入正确验证码")
                        return false;
                    }
                    $('input[name=code]').val(value)
                    ajaxSubmit();
                });
            }, 'html')
        }
    })

</script>
{/block}
